package com.letao.demo.controllers;

import com.letao.demo.dao.CreateFoodDao;
import com.letao.demo.models.CreateFood;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by luxin on 2017/3/1.
 */
@RestController
public class IndexController {

    @RequestMapping("/")
    public String indexShow(){
        return "Hello hahaha";
    }

    @Autowired
    private CreateFoodDao createFoodDao;

    @RequestMapping("/create")
    public Object create(){
        CreateFood createFood =new CreateFood();
        createFood.setName("Orange");
        return createFoodDao.save(createFood);

    }

    @RequestMapping("/showall")
    public Object showAll(){
        return createFoodDao.findAll();
    }
}
